package org.myOrg.spetrum.Driver;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;

import org.myOrg.spetrum.spectrumStruct.Spectrum;
import org.myOrg.spetrum.spectrumStruct.SpectrumFactory;

public class SpectrumUnion {
	private HashMap<Integer, Spectrum> spectrums;

	public SpectrumUnion() {
		spectrums = new HashMap<Integer, Spectrum>();
		init();
	}
	public Iterator<Entry<Integer, Spectrum>> itertor(){
		return spectrums.entrySet().iterator();
	}

	private void init() {
		addSpetrum(SpectrumFactory.BASE);
		addSpetrum(SpectrumFactory.DEEPFIRST);
		addSpetrum(SpectrumFactory.WIDTHFIRST);
		addSpetrum(SpectrumFactory.GREEDY);
		addSpetrum(SpectrumFactory.PATH);
	}

	private void addSpetrum(int type) {
		Spectrum spectrum = SpectrumFactory.generateSpectrum(type);
		spectrums.put(new Integer(type), spectrum);
	}

	public Spectrum getSpectrum(int type) {
		return spectrums.get(new Integer(type));
	}

	public void clear() {
		Iterator<Entry<Integer, Spectrum>> itr = spectrums.entrySet()
				.iterator();
		while (itr.hasNext()) {
			itr.next().getValue().clear();
		}
	}
}
